package com.zhuiyun.project.api.venuemanagement.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.venuemanagement.entity.BanRecord;
import com.zhuiyun.project.api.venuemanagement.entity.VenueManagement;
import com.zhuiyun.project.api.venuemanagement.service.VenueBanService;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName VenueBanController
 * @Description TODO
 * @Author wuwan
 * @Date 2023/12/6 10:20
 **/
@RestController
@Api(tags = "场馆管理")
@Slf4j
@RequestMapping("/VenueBan")
public class VenueBanController {
    @Autowired
    private VenueBanService venueBanService;
    /*
    * @Author wuwan
    * @Description 查询所有被封禁的场馆
    * @Date 2023/12/6 10:24
    * @Return
    */
    @GetMapping("/selectVenueBan")
    @ApiOperation(value = "查询所有被封禁的场馆")
    @OptLog(modular = "场馆管理",type = CommonConstants.SELECT,describe = "查询所有被封禁的场馆")
    public CommonResult selectVenueBan(PageRequest pageRequest, String userName, String phone){
        return CommonResult.ok(venueBanService.selectVenueBan(pageRequest,userName,phone));
    }
    /*
    * @Author wuwan
    * @Description 场馆账号解封
    * @Date 2023/12/6 11:50
    * @Return
    */
    @PutMapping("/changeUserStatusBan")
    @ApiOperation(value = "场馆账号解封")
    @OptLog(modular = "场馆管理",type = CommonConstants.SELECT,describe = "场馆账号解封")
    public CommonResult changeUserStatusBan(@RequestBody BanRecord banRecord){
        return CommonResult.ok(venueBanService.changeUserStatusBan(banRecord));
    }
    /*
    * @Author wuwan
    * @Description 查询封禁历史记录
    * @Date 2023/12/6 14:18
    * @Return
    */
    @GetMapping("/getVenueBanRecord")
    @ApiOperation(value = "查询封禁历史记录")
    @OptLog(modular = "场馆管理",type = CommonConstants.SELECT,describe = "查询封禁历史记录")
    public CommonResult getVenueBanRecord(String venueUniqueIdentifier){
        return CommonResult.ok(venueBanService.getVenueBanRecord(venueUniqueIdentifier));
    }
    /*
    * @Author wuwan
    * @Description 自动解封
    * @Date 2023/12/6 19:11
    * @Return
    */
    @Scheduled(cron = "30 0 0 * * ?")// 每天凌晨0点0分30秒执行
    public void changeLiftBan() {
        venueBanService.changeLiftBan();
    }
    /*
    * @Author wuwan
    * @Description 授权自动取消
    * @Date 2023/12/6 19:11
    * @Return
    */
    @Scheduled(cron = "0 * * * * ?")// 每分钟执行一次
    public void changeAuthorizationExpiredTime() {
        venueBanService.changeAuthorizationExpiredTime();
    }
}
